package com.ly.mpayment.persist.service.uporder;

import java.util.List;
import java.util.Map;

import com.ly.mpayment.persist.entity.DownRechargeFlow;
import com.ly.mpayment.persist.entity.UpOrder;
import com.ly.mpayment.persist.entity.UpShopInfo;
import com.ly.mpayment.persist.entity.UpShopProduct;
import com.ly.mpayment.persist.entity.yidong.MobileOrders;
import com.ly.mpayment.persist.hibernate.Page;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public interface IUporderService {

	public UpOrder saveOrder(UpOrder order);

	public UpOrder updateOrder(UpOrder order,UpShopInfo shop);

	public UpOrder updateOrder(UpOrder order);

	public UpOrder updateOrderMatch(UpOrder order);

	public UpOrder findById(String orderuuid);

	public UpOrder findByIdNormal(String orderuuid);

	public UpOrder findByIdFail(String orderuuid);

	public UpOrder findByIdSuccess(String orderuuid);

	public UpOrder findByCallId(String orderId);

	public UpOrder findByShopId(String orderuuid);

	public UpOrder findByWeiLiuTaskId(String taskId,String orderuuid);

	public UpOrder findByheifeixinOrderId(String childOrder);

	public UpOrder findByUpOrderId(String upOrderId);

	public UpOrder findByFlowChildOrder(String childOrder);

	/**
	 * 订单成功之后执行 并且需要减去上游渠道商账户余额
	 * @param order
	 * @param shop
	 * @return
	 */
	public DownRechargeFlow updateOrderBalance(UpOrder order,DownRechargeFlow flow,UpShopInfo shop) throws Exception;

	/**
	 * 查询充值中的订单 状态为1
	 * @param downId
	 * @return
	 */
	public UpOrder findByDownFlowId(String downId);

	public UpOrder findByDownFlowIdSql(String downId);

	public UpOrder findByDownFlowIdSqlMaintenances(String downId);

	/**
	 *
	 * @param downId
	 * @return
	 */
//	public UpOrder findByDownFlowIdFail(String downId);
//
//	public UpOrder findByDownFlowIdSuccess(String downId);

	public Page<UpOrder> findPageOrder(Map<String, Object> parameters,int start,int pageSize,boolean oderBy);

	public int updateOrderStatus(List<UpOrder> list);
	/**
	 * 定时查询为回调的订单 发起查询
	 * @return
	 */
	public List<UpOrder> findOrders(Integer pageSize,int start,int minutes);

	public List<UpOrder> orderCommitFailt(Integer pageSize, int start);

	public String getUpCount(Map<String, Object> parameter, int start, int pageSize);

	public JSONArray exportDataUp(Map<String, Object> parameter);

	public UpOrder findOrderProduct(String uporderuuid);

	public List findDiscount();

//	public List findBackAmount();

	public List<UpOrder> exportdataUpOrder(Map<String, Object> parameter);

	UpOrder findBackAmountOrderId(String uporderuuid);


	public JSONArray countProfit(Map<String, Object> parameter,int start,int pageSize);

	UpOrder findBySantiOrderId(String orderId);

	/**
	 * 电子卷
	 * @param uporderuuid
	 * @return
	 */
	public UpOrder findByEleId(String uporderuuid);

	public UpOrder findLeXiang(String string);

	/**
	 * 查询和飞信产品
	 *
	 * @param products 和飞信产品列表
	 * @return
	 */
	public List<UpOrder> findHeFeixinProduct(String products);

	public void updateUpOrder(UpOrder order,  String upOrderId);

	public String findUpFlowCount(JSONObject json,  int start, int pageSize);

	public JSONArray exportDataUpFlow(JSONObject json);


//	public void commitZhongYou(UpOrder order);
	public void commitFailt(UpOrder order,  String msg);

	public void addOrderMsg(UpOrder order, String msg);

//	public void updateMobileOrder(int i, String msg, MobileOrders mobileOrder, String result);

	public void updateUpOrderMsg(UpOrder order,  String upOrderId,String msg);

	UpOrder findByDownFlowRechare(String downorderuuid);
	/**
	 * 转人工
	 * @param order
	 * @param upOrderId
	 */
	public void updateUpOrderArtificial(UpOrder order, String upOrderId,String msg);

	UpOrder batchCommitOrder(UpShopProduct upShopProduct,UpOrder upOrder,UpShopInfo upShopInfo);

	UpOrder findByPressOrder(String uporderuuid);

	UpOrder findByIdFailUpOrder(String downorderuuid);

    List<UpOrder> findByDownOrderId(String downorderuuid);

	String countProfitRate(Map<String, Object> parameters, int start, int pageSize);

	String countDownProfit(Map<String, Object> parameters, int start, int pageSize);

    String findByFlowOrder(DownRechargeFlow flow);

	int upCount(String downorderuuid);

	int findbyProduct(String upprouuid);

	List<UpOrder> savePageOrderQh(Map<String, Object> parameters, int i, int pageSize, boolean b);

	/**
	 * 查询订单充值的订单
	 * @param uporderuuid
	 * @return
	 */
	UpOrder findByIdWait(String uporderuuid);
}
